package Satellites;

public class Coordinates {
	
	
	public static final double raioTerra = 6378.14; //Raio da Terra em metros
	
	
	private double longitude;
	private double latitude;
	private double height;
	
	
	public Coordinates(final double longitude, final double latitude){
		this.latitude = latitude;
		this.longitude = longitude;
		this.height = 0.0;
	}
	
	public double calculateElevation(){
		
		return 0.0;
	}

	public double calculateAzimuth(Coordinates base){
		double L = Math.abs(base.getLat()-longitude);
		double a = Math.acos( (Math.sin(L)) / (Math.sqrt(  1-Math.pow(Math.cos(L),2) * Math.pow(Math.cos(base.getLat()),2))));
		if(base.getLat() > latitude && base.getLong() > longitude)
			return (Math.PI + a);
		else if(base.getLat() > latitude && base.getLong() < longitude)
			return (Math.PI - a);
		else if(base.getLat() < latitude && base.getLong() > longitude)
			return (2*Math.PI - a);
		else
			return a;
	}
	
	public void setLong(double x){
		longitude = x;
	}
	
	public void setLat(double x){
		latitude = x;
	}
	
	public void setHeight(double z){
		height = z;
	}
	
	
	public double getLong(){
		return longitude;
	}
	
	public double getLat(){
		return latitude;
	}
	
	public String prettyCoord(){
		String c = null;
		if((longitude < 0.0) && (latitude < 0.0))
			c = "Long: " + Math.abs(longitude) + " W Lat: " + Math.abs(latitude) + " S";
		else if((longitude > 0.0) && (latitude < 0.0))
			c = "Long: " + Math.abs(longitude) + " E Lat: " + Math.abs(latitude) + " S";
		else if((longitude < 0.0) && (latitude > 0.0))
			c = "Long: " + Math.abs(longitude) + " W Lat: " + Math.abs(latitude) + " N";
		else
			c = "Long: " + Math.abs(longitude) + " E Lat: " + Math.abs(latitude) + " N";	
		return c;
	}
	

}
